package ar.com.unlp.fi.lrs.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import ar.com.unlp.fi.lrs.domain.Statement;
import ar.com.unlp.fi.lrs.persist.StatementDao;

@Service
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
@Transactional
public class ContextService {

	
	StatementDao statementDao=new StatementDao();
	
	/**
	 * Se agrega al contexto de stamement un substament.
	 * 
	 * 
	 * @param idStatement
	 * @param subStatement
	 */
	public void addExtension(long idStatement, Statement subStatement){
		
		Statement statement= statementDao.get(idStatement);
		statement.getContext().getExtensions().add(subStatement);
		
		statementDao.update(statement);
		
		
	}
	
	/**
	 * 
	 * 
	 * 
	 * @param idStatement
	 * @return
	 */
	public List<Statement> getExtensions(long idStatement){
		
		Statement statement= statementDao.get(idStatement);
		List<Statement> statementsRelated =statement.getContext().getExtensions();
		
		return statementsRelated;
	}
	
	
	
	
	
	
}
